package com.neural.runner;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;

import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;

import com.neural.descriptor.FeedDescriptor;
import com.neural.descriptor.NetDescriptor;
import com.neural.descriptor.ResultPojo;
import com.neural.infrastructure.Net;
import com.neural.printer.NetPrettyPrinter;

public class Main {

	private static String[] tests = { "2.A", "2.B", "3.A", "3.B",							// 0-3
										"2.A.test", "2.B.test", "3.A.test", "3.B.test" };	// 4-7

	public static void main(String[] args) throws IOException {

		String testCase = tests[0];

		Yaml yaml = new Yaml(new Constructor(NetDescriptor.class));
		NetDescriptor netDescriptor = (NetDescriptor) yaml.load(new FileInputStream("resources/" + testCase + "/net.yaml"));
		Net net = new Net(netDescriptor);

		NetPrettyPrinter.printKohnenStates(net.returnKohonenNeuronsState());
		yaml = new Yaml(new Constructor(FeedDescriptor.class));
		FeedDescriptor feedDescriptor = (FeedDescriptor) yaml.load(new FileInputStream("resources/" + testCase + "/feed.yaml"));
		List<ResultPojo> resultPojos = net.feedAndComputeNet(feedDescriptor);
		NetPrettyPrinter.printKohnenStates(net.returnKohonenNeuronsState());
		NetPrettyPrinter.printResults(resultPojos.subList(resultPojos.size() - 9, resultPojos.size()));
	}
}
